package com.android.justcook.tests;

import java.util.*;
import java.util.Hashtable;

import android.util.Log;

import com.android.justcook.sqlite.Recipe;
import com.android.justcook.sqlite.RecipesDataSource;
import com.android.justcook.sqlite.Relationship;


/*

 */


public class DataBaseTest {
	private final String TAG = "DATABASE_TEST";
	
	public void fillDatabase(RecipesDataSource dataSource) { 
		try {
			dataSource.open();
		
			
			/*
			 test offers
			1, "a", 1, "pork, beef, eggs", "cook it", 0, 0, "./", "utre" , 00
			2, "b", 2, "pork, beef, eggs", "cook it", 1, 0, "./", "utre" , 11
			3, "c", 3, "pork, beef, eggs", "cook it", 0, 1, "./", "utre" , 22
			
			 */
			Log.d(TAG, "Clearing database...");
			
			dataSource.trunkateDatabase();
			
			Log.d(TAG, "Filling database...");
			
			dataSource.insertRecipe(new Recipe(1, "a", 1, "pork, beef, eggs", "cook it",
					0, 0, "./", "utre", 00));
			

			dataSource.insertRecipe(new Recipe(2, "b", 2, "pork, beef, eggs", "cook it",
					0, 1, "./", "utre", 00));

			dataSource.insertRecipe(new Recipe(3, "c", 3, "pork, beef, eggs", "cook it",
					1, 0, "./", "dnes", 00));
			
			dataSource.insertRelationship(new Relationship(1,1));
			
			dataSource.insertRelationship(new Relationship(2,1));

			dataSource.insertRelationship(new Relationship(3,2));
			
			Log.d(TAG, "Database filled");
			
			Hashtable<Integer, Hashtable<String,String>> ht = dataSource.getAllCategoryRecepies(1);
			if(ht.size()!=2) Log.d(TAG, "incorrect");
			
		} catch (Exception e) {
			e.printStackTrace();
			dataSource.close();
		}
	}
	
	
}
